package com.tech.cloudapp.controller;


import com.tech.cloudapp.biz.service.IBQuestionInfoService;
import com.tech.cloudapp.db.entity.QuestionInfo;
import com.tech.cloudapp.dto.PageDTO;
import com.tech.cloudapp.model.CommonResponseDO;
import com.tech.cloudapp.po.QuestionInfoPO;
import com.tech.cloudapp.po.QuestionPaperPO;
import com.tech.cloudapp.util.BeanCopyUtils;
import com.tech.cloudapp.util.ValidatorUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 题目信息表 前端控制器
 * </p>
 *
 * @author mojianyou
 * @since 2025-03-23
 */
@RestController
@RequestMapping("/question-info")
public class QuestionInfoController {


    @Autowired
    private IBQuestionInfoService bQuestionInfoServiceImpl;


    @PostMapping("list")
    public CommonResponseDO list(@RequestBody com.tech.cloudapp.po.QuestionInfoPO questionInfoPO)
    {
        ValidatorUtils.validate(questionInfoPO);
        QuestionInfo questionInfo = BeanCopyUtils.copyBean(questionInfoPO, QuestionInfo.class);
        List<QuestionInfo> list = bQuestionInfoServiceImpl.list(questionInfo);
        return CommonResponseDO.success(list);
    }


    @PostMapping("page")
    public CommonResponseDO page(@RequestBody QuestionInfoPO questionInfoPO)
    {
        ValidatorUtils.validate(questionInfoPO);
        // QuestionPaper questionPaper = BeanCopyUtils.copyBean(questionPaperPO,QuestionPaper.class);
        PageDTO page = bQuestionInfoServiceImpl.page(questionInfoPO);
        return CommonResponseDO.success(page);
    }
}

